/**
 * Copyright (C) 2009-2012, KingHool.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses.
 */
package com.kinghool.smodel;

import java.util.List;

import com.kinghool.ebos.commons.utils.Assert;
import com.kinghool.ebos.commons.utils.Utils;

/**
 * 
 * @Author Allen Deng(dengtailin@gmail.com) 
 */
public class ValidationResult {
	private final List<String> errMsgs = Utils.newList();
	private final List<String> warnMsgs = Utils.newList();
	
	public final static ValidationResult OK = new ValidationResult(null, null);
	 
	public static ValidationResult valueOf(List<String> errMsgs, List<String> warnMsgs) {
		return new ValidationResult(errMsgs, warnMsgs);
	}
	
	private ValidationResult(List<String> errMsgs, List<String> warnMsgs) {
		if (!Assert.isNullOrEmpty(errMsgs)) {
			this.errMsgs.addAll(errMsgs);
		}
		if (!Assert.isNullOrEmpty(warnMsgs)) {
			this.warnMsgs.addAll(warnMsgs);
		}
	} 
	
	public List<String> getErrMsgs() {
		return errMsgs;
	} 
	public List<String> getWarnMsgs() {
		return warnMsgs;
	} 
	
	public boolean isOK() {
		return Assert.isNullOrEmpty(errMsgs) && Assert.isNullOrEmpty(warnMsgs);
	}
	
	public boolean isValid() {
		return Assert.isNullOrEmpty(errMsgs);
	}
	
	public boolean isWarning() {
		return Assert.isNullOrEmpty(warnMsgs);
	}
}
